//
// Created by wze-zero on 2024/10/27.
//
#include <iostream>

using namespace std;

int main() {
    int n, m, k, a, b;
    char t;
    cin >> n >> m;
    int arr[n][m];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> arr[i][j];
        }
    }
    cin >> k;
    for (int i = 0; i < k; ++i) {
        cin >> t >> a >> b;
        if (t == 'r') {
            for (int j = 0; j < m; ++j) {
                int temp = arr[a - 1][j];
                arr[a - 1][j] = arr[b - 1][j];
                arr[b - 1][j] = temp;
            }
        } else if (t == 'c') {
            for (int j = 0; j < n; ++j) {
                int temp = arr[j][a - 1];
                arr[j][a - 1] = arr[j][b - 1];
                arr[j][b - 1] = temp;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cout << arr[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}